//
// Created by jsjxsy on 2022/8/18.
// << 只能作为友元函数
//
#include <iostream>
using namespace std;
class Point {
 public:
  Point(int x = 0, int y = 0) : x(x), y(y) {
    cout << "construct Point(x=" << x << ",y=" << y << ")" << endl;
  }

// point 后面不能再使用<<输出
//  friend void operator<<(ostream &os, const Point &point) {
//    os << "Point(x=" << point.x << ",y=" << point.y << ")" << endl;
//  }

  friend ostream &operator<<(ostream &os, const Point &point);
  friend istream &operator>>(istream &is, Point &point);
  int x;
  int y;
};

// 必须返回 return, 没有return居然不报错
ostream &operator<<(ostream &os, const Point &point) {
  return os << "Point(x=" << point.x << ",y=" << point.y << ")";
}
istream &operator>>(istream &is, Point &point) {
  return is >> point.x >> point.y;
}

int main() {
  Point p1(1, 1);
  Point p2(3, 5);
  cout <<"p1="<< p1 << endl;
  cout << p2 << endl;
  Point p3;
  cin >> p3;
  cout << p3 << endl;
  return 0;
}
